package ccc.hqu.edu.cn.whatmaps;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.baidu.mapapi.search.core.PoiInfo;

import java.util.List;

//searchActivity用

public class LocNearAddressAdapter extends BaseAdapter {
    private List<PoiInfo> nearList;
    private LayoutInflater mInflater;
    private Context context;

    public LocNearAddressAdapter(Context context, List<com.baidu.mapapi.search.core.PoiInfo> nearList) {
        this.nearList = nearList;
        this.context = context;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    @Override
    public int getCount() {
        return nearList.size();
    }

    @Override
    public Object getItem(int arg0) {
        return nearList.get(arg0);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View view, ViewGroup viewGroup) {
        com.baidu.mapapi.search.core.PoiInfo mPoiInfo = nearList.get(position);
        view = View.inflate(context,R.layout.poi_list,null);
        TextView txTitle = view.findViewById(R.id.poiName);
        txTitle.setText(mPoiInfo.name);
        TextView txDate = view.findViewById(R.id.poiLocation);
        txDate.setText(mPoiInfo.address);
        return view;
    }
}
